var e = require("../../../../@babel/runtime/helpers/createForOfIteratorHelper"), t = getApp();

Page({
    data: {
        codeList: [],
        codeLoading: !1,
        codeFinished: !1,
        codeLoadPage: 1
    },
    onLoad: function(e) {
        this.getCodes(), wx.setNavigationBarTitle({
            title: "升级码"
        });
    },
    onPullDownRefresh: function() {
        var e = this;
        this.setData({
            codeList: [],
            codeLoading: !1,
            codeFinished: !1,
            codeLoadPage: 1
        }, function() {
            e.getCodes();
        });
    },
    onReachBottom: function() {
        this.getCodes();
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {},
    getCodes: function() {
        var a = this;
        if (!0 !== this.data.codeLoading && !0 !== this.data.codeFinished) {
            this.setData({
                codeLoading: !0
            });
            var o = t.getNetAddresss("plugin.upgrade-code.Frontend.controllers.list.index");
            t._getNetWork({
                url: o,
                data: {
                    page: this.data.codeLoadPage
                },
                success: function(t) {
                    var o = t.data, d = o.data, i = o.result, n = o.msg;
                    if (i) {
                        var l = d.data, s = d.current_page, r = d.last_page, c = d.per_page, v = {
                            codeLoading: !1,
                            codeLoadPage: a.data.codeLoadPage + 1
                        };
                        (s == r || c < l.length) && (v.codeFinished = !0);
                        var g, _ = e(l);
                        try {
                            for (_.s(); !(g = _.n()).done; ) {
                                var u = g.value;
                                u.member_level && u.dividend_level ? u._level_text = u.member_level.level_name + " + " + u.dividend_level.level_name : u.member_level ? u._level_text = u.member_level.level_name : u.dividend_level && (u._level_text = u.dividend_level.level_name);
                            }
                        } catch (e) {
                            _.e(e);
                        } finally {
                            _.f();
                        }
                        var h = a.data.codeList;
                        h = h.concat(l), v.codeList = h, a.setData(v), wx.stopPullDownRefresh();
                    } else wx.showToast({
                        title: n,
                        icon: "none",
                        duration: 1500,
                        complete: function() {
                            wx.redirectTo({
                                url: "/packageG/member_v2/member_v2"
                            });
                        }
                    });
                }
            });
        }
    }
});